/**
 * 人才库-推荐到岗位/推荐到其他岗位
 */
import React, { useState } from 'react';
import { withRouter } from 'umi';
import AuthComponent from '@/utils/auth/AuthComponent';
import { Icon } from '../../components';
import TalentsRecommendModal from './TalentsRecommendModal';

function TalentsRecommendOperate({ operateType, onRefresh, ...rest }) {
    const [visible, setVisible] = useState(false);
    const [title] = useState(operateType === 'common' ? '推荐到岗位' : '推荐到其他岗位');
    return (
        <AuthComponent code="office:recruitment:course:interview:add">
            <Icon
                {...rest}
                type="iconlistfunction_out"
                title={title}
                onClick={() => {
                    setVisible(true);
                }} />
            <TalentsRecommendModal
                title={title}
                operateType={operateType}
                visible={visible}
                onCancel={() => { setVisible(false) }}
                onOk={() => {
                    setVisible(false);
                    onRefresh();
                }}
                {...rest}
            />
        </AuthComponent>
    );
}
export default withRouter(TalentsRecommendOperate);
